'/*****************************************************************************
'*   (c) Copyright Kofax Image Products, 2006 All rights reserved.
'*   Unauthorized use, duplication or distribution is strictly prohibited.
'******************************************************************************
'*
'*  File:       SampleWorkflowCtrl.ctl
'*
'*  Purpose:    Sample workflow Ctrl controller. Link between Ascent Capture
'*              application and the workflow agent setup.
'*
'*
'*****************************************************************************/

Option Explicit On 
Imports System.Runtime.InteropServices
Imports Kofax.AscentCaptureAdminMod


<GuidAttribute("B4418E43-A98D-5B54-A76F-1F8A2CD4ACE2"), _
ClassInterface(ClassInterfaceType.AutoDispatch), _
ProgId("SampleWorkflowSetup.net.SampleWorkflowCtrl"), _
CLSCompliant(False)> _
Public Class AllStateBatchRouterWorkflowCtrl
    Inherits System.Windows.Forms.UserControl

    Private m_oApp As AdminApplication
    Private m_oWorkflowAgentSetup As New AllStateBatchRouterWorkflowAgentSetup

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'UserControl1 overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        components = New System.ComponentModel.Container
    End Sub

#End Region


    '**************************************************
    '*** Function:  Application
    '*** Purpose:   Sets the application object - Base of hierarchy
    '*** Input:     none
    '*** Output:    none
    '**************************************************
    Public WriteOnly Property Application() As AdminApplication
        Set(ByVal Value As AdminApplication)
            Try
                m_oApp = Value
                m_oWorkflowAgentSetup.SetApp(m_oApp)

            Catch ex As Exception
                MsgBox("Application error")
            End Try
        End Set
    End Property

    '**************************************************
    '*** Function:  ActionEvent
    '*** Purpose:   Receive each action event
    '***            Look for menu selection
    '*** Input:     nActionNumber - number assigned to
    '***                            event
    '*** Output:    vArgument - currently NOT used
    '***            pnCancel - Response to the event.
    '***                       Only DocumentClosing and
    '***                       FieldExiting process the response
    '*** Return:    ActionEvent returned is currently ignored.
    '**************************************************
    Public Function ActionEvent(ByVal nActionNumber As Integer, _
                                ByRef vArgument As Object, _
                                ByRef pnCancel As Integer) As Integer
        '*** Set the return values
        pnCancel = 0
        ActionEvent = 0

        '*** Menu clicked event
        If nActionNumber = KfxOcxEvent.KfxOcxEventMenuClicked Then

            '*** Special menus that must be added to registry.
            '*** To test this add "NET Workflow Agent Test Menu" as a EventText
            If vArgument = "NET Workflow Agent Test Menu" Then
                m_oWorkflowAgentSetup.ShowDialog(Me)
            End If
        End If
    End Function

End Class
